Shifted Exponential

Let \(X_1,\ X_2,\ldots,\ X_n\) be iid \(f_X(x,\alpha, \beta)\) where \[ f_X(x,\alpha, \beta) = \left\{\begin{array}{ll} {1 \over \beta} \exp\left({\alpha-x \over \beta}\right) & x \ge \alpha \\ 0 & \mbox{else} \end{array} \right. \] for \(-\infty < \alpha < \infty\) and \(\beta > 0.\) Then \[\begin{eqnarray*} f_\mathbf{X}(\mathbf{x}, \alpha, \beta) & = & \prod_{i=1}^n {1 \over \beta} \exp\left({\alpha - x_i \over \beta}\right) I(x_i \ge \alpha) \\ & = & \beta^{-n} \exp\left({n\alpha \over \beta} - {\sum x_i \over \beta}\right) I(x_{(1) \ge \alpha}) \end{eqnarray*}\]

For a single \(X\), that is \(n=1\), we see

  alpha <- 2
  beta <- 3
  x <- seq(0,10,by=0.01)
  f <- function(x){1/beta * exp((alpha - x)/beta) * (x >= alpha)}
  plot(x, f(x), type="l")

  curve(f(x), from=alpha, to=10, xlim=c(0,10), ylim=c(-0.01,0.4), xlab="x", ylab="f", col="blue")
  curve(0*x, from=0, to=alpha, add=TRUE, col="blue")

The associated likelihood function is

  x1 <- 4
  beta <- 3
  alpha <- seq(-5, 10, by=0.01)
  L <- function(alpha){1/beta * exp((alpha - x1)/beta) * (x1 >= alpha)}
  plot(alpha, L(alpha), type="l")

  curve(L(x), from=-5, to=x1, xlim=c(-5,10), ylim=c(-0.01,0.4), xlab="alpha", ylab="f", col="blue")
  curve(0*x, from=x1, to=10, add=TRUE, col="blue")

For two \(X_i\)’s, that is \(n=2\), we have \(f_{\mathbf{X}}\left(\mathbf{x}|\alpha, \beta \right)\)

  p_load(rgl)

  ### Make data for alpha = 2 and beta = 3, and x1 = x2 between 0 and 10
  alpha <- 2
  beta <- 3
  x1 <- seq(0, 10, by=0.05)
  x2 <- x1
  length(x1)
## [1] 201
  Data <- expand.grid(x=x1, y=x2)
  dim(Data)
## [1] 40401     2
  Data$f <- 1/beta^2 * exp((2*alpha/beta - (Data$x + Data$y)/beta)) * (Data$x >= alpha) * (Data$y >= alpha)

  ### plot in 3d
  plot3d(Data)

Or, we can plot it using a wireframe as below.

  ### Generate a matrix of heights
  f <- matrix(Data$f, ncol=length(x1))

  ### Plot the heights in the f matrix and the points given by combinations
  ### of the values in x1 and x2
  persp3d(x=x1, y=x2, z=f)

The plotly package has some nice graphs.

  ### Install or load the plotly package
  p_load(plotly)

  ### Let plotly know the axis values in vectors, and the height in a matrix
  (n1 <- length(x1))
## [1] 201
  (n2 <- length(x2))
## [1] 201
  dim(f)
## [1] 201 201
  n1 * n2
## [1] 40401
  p <- plot_ly(x = ~x1, y = ~x2, z = ~f) 
  
  ### Make it a surface plot
  p %>% add_surface()
  ### Try a contour plot
  p %>% add_contour(contours = list(showlabels = TRUE), line = list(smoothing = 0.0)) %>%
  colorbar(title = "f(x1,x2)")
  ### A surface plot with a contour plot
  p %>% add_surface(contours = list(
      z = list(
      show=TRUE,
      usecolormap=TRUE,
      highlightcolor="#ff0000",
      project=list(z=TRUE)
      )
    )
  ) %>%
  layout(
    scene = list(
      camera=list(
        eye = list(x=1.87, y=0.88, z=-0.64)
        )
      )
  ) %>% colorbar(title = "f(x1,x2)")

The joint likelihood function, \(L(\mathbf{\theta} | \mathbf{X} = \mathbf{x})\), is plotted below.

  x <- 7
  y <- 8
  alpha <- seq(0.5, 10, by=0.1)
  beta <- seq(0.1, 5, by=0.1)
  Data <- expand.grid(x=alpha, y=beta)
  Data$f <- 1/Data$y^2 * exp((2*Data$x/Data$y - (x + y)/Data$y)) * (x >= Data$x) * (y >= Data$x)
  L <- matrix(Data$f, ncol=length(alpha), byrow=TRUE)
  
  ### Define the axes
  x.axis <- list(
    title = "alpha",
    titlefont = f
  )
  y.axis <- list(
    title = "beta",
    titlefont = f
  )

  ### Let plotly know the axes values (in vectors) and the height (in matrix)
  p <- plot_ly(x = ~alpha, y = ~beta, z = ~L)%>%
    layout(xaxis = x.axis, yaxis = y.axis)
 
  ### Create a contour plot
  p %>% add_contour(contours = list(showlabels = TRUE), line = list(smoothing = 0.0)) %>%
  colorbar(title = "L(alpha, beta)") 
  ### Create a surface plot with a contour plot
  p %>% 
    add_surface(contours = list(
        z = list(
        show=TRUE,
        usecolormap=TRUE,
        highlightcolor="#ff0000",
        project=list(z=TRUE)
        )
      )
    ) %>%
    layout(
      scene = list(
        camera=list(
          eye = list(x=1.87, y=0.88, z=-0.64)
          )
        )
    ) %>% 
    colorbar(title = "L(alpha, beta)")